//
//  XQCustomEngeLabel.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/21.
//

#import "XQCustomEngeLabel.h"

@implementation XQCustomEngeLabel

//初始化edgeInsets
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.edgtInsets = UIEdgeInsetsMake(4, 0, 4, 0);
    }
    return self;
}

-(instancetype)initWithCoder:(NSCoder *)coder{
    if (self = [super initWithCoder:coder]) {
        self.edgtInsets = UIEdgeInsetsMake(4, 0, 4, 0);
    }
    return self;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    self.edgtInsets = UIEdgeInsetsMake(4, 0, 4, 0);
}

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines{
    CGRect rect = [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, self.edgtInsets) limitedToNumberOfLines:numberOfLines];
    rect.origin.x -= self.edgtInsets.left;
    rect.origin.y -= self.edgtInsets.top;
    rect.size.width += self.edgtInsets.left + self.edgtInsets.right;
    rect.size.height += self.edgtInsets.top + self.edgtInsets.bottom;
    return rect;
}

- (void)drawTextInRect:(CGRect)rect{
    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.edgtInsets)];
}
@end
